home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu248.dms / pu248.adf / Intuition / Miscellaneous / Example1.c < prev    next >
C/C++ Source or Header  |  1992-05-01  |  2KB  |  51 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE) V3.0      Amiga C Club (ACC) */
  4. /* -------------------------------      ------------------ */
  5. /*                                                         */
  6. /* Book:    ACM Intuition               Amiga C Club       */
  7. /* Chapter: Miscellaneous               Tulevagen 22       */
  8. /* File:    Example1.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    92-05-01                                       */
  11. /* Version: 1.10                                           */
  12. /*                                                         */
  13. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This example shows how to allocate, and deallocate memory. */
  21.  
  22.  
  23. #include <exec/types.h>  /* Declares CPTR. */
  24. #include <exec/memory.h> /* Declares MEMF_CHIP. */
  25.  
  26.  
  27. main()
  28. {
  29.   /* Declare a pointer to the memory you are going to allocate: */
  30.   CPTR memory;
  31.  
  32.  
  33.   /* Allocate 150 bytes of Chip memory: */
  34.   memory = (CPTR) AllocMem( 150, MEMF_CHIP );
  35.  
  36.  
  37.   /* Have we allocated the memory successfully? */
  38.   if( memory == NULL )
  39.   {
  40.     printf("Could not allocate the memory!\n");
  41.     exit();
  42.   }
  43.  
  44.  
  45.   /* Do whatever you want to do with the memory! */
  46.   
  47.  
  48.   /* Free the memory we have previously allocated: */
  49.   FreeMem( memory, 150 );  
  50. }
  51.